<template>
	<view style="width: 100%;height: auto;display: block;float: left;">
		<view class="cy_list">
			<view class="cy_li" v-for="(item,index) in list" :key="index">
				<text class="cy_li_tit t5">{{item.createdTime}}</text>
				<text class="cy_li_tit t20 tri">{{item.amount/100}}元</text>
			</view>
		<view class="zanwu" v-show="jiazai" style="padding-top: 4vw;"><text class="t7">{{more}}</text></view>
		<view class="zanwu" v-show="zanwu" style="padding:4vw 0;">
			<image src="../../static/img/kong.png" mode="widthFix" style="margin-left: 25vw;"></image><text class="t8">{{wu}}</text>
		</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				mainid: '',
				list: [],
				pages: 1,
				ismore: true,
				more: '加载更多',
				jiazai: false,
				wu: "暂无记录",
				zanwu: false,
				type:'',
				id:'',
			}
		},
		onLoad(opt) {
			var _this = this;
			if(opt.id){
				_this.id=opt.id;
			}
			uni.getStorage({
				key: 'user',
				success: function(res) {
					_this.mainid = res.data.id;
					_this.hblog();
				}
			});
		},
		methods: {
			//获取红包发放记录列表
			hblog() {

				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'mch/redLogPage/' + this.id+'/' + this.pages, //仅为示例，并非真实接口地址。
					method: 'post',
					data: {
						id: this.id, //	用户ID（mainId）		true	string
						page: this.pages, //	page
					},
					success: (res) => {
						uni.hideLoading(); //关闭加载动画						
						console.log("红包列表: ",res);
						if (res.data.status == '200') {

							if (res.data.data.pages==this.pages) {
								this.more = "没有更多数据了";
								this.jiazai = true;
								this.zanwu = false;
								this.ismore = false;
							} else if (res.data.data.pages == 0) {
								this.more = "暂无数据";
								this.jiazai = false;
								this.zanwu = true;
								this.ismore = false;
							} else {
								this.more = "加载更多";
								this.jiazai = true;
								this.zanwu = false;
								this.ismore = true;
							}
											if (this.pages == 1) {

												this.list = res.data.data.records;
											} else {
												for (var i = 0; i < res.data.data.length; i++) {
													this.list.push(res.data.data.records);
												}
											}
						}
					},
					fail: (error) => {
						uni.hideLoading();
						// this.checks = true
						uni.showToast({
							title: error,
							icon: 'none',
							duration: 2000
						});
						console.log(error)
					}
				});
			}
		}
	}
</script>

<style>
	.loading {
		text-align: center;
		line-height: 10vw;
	}

	.cy_user {
		width: 90%;
		height: auto;
		display: block;
		float: left;
		margin: 2vw 5%;
		background: -webkit-linear-gradient(#8A3DE2, #9C4BF9);
		background: -o-linear-gradient(#8A3DE2, #9C4BF9);
		background: -moz-linear-gradient(#8A3DE2, #9C4BF9);
		background: linear-gradient(#8A3DE2, #9C4BF9);
		border-radius: 1vw;
		padding: 4vw;
		box-shadow:0px 0px 5px #F2F2F2;
	}

	.cy_user_tit {
		width: 100%;
		height: 18vw;
		line-height: 8vw;
		display: block;
		float: left;
		text-align: left;
		margin-bottom: 2vw;
		border-bottom: 1px solid #fff;
		text-align: center;
		padding-bottom: 2vw;
	}

	.cy_user_into {
		width: 33.33%;
		height: auto;
		display: block;
		float: left;
		line-height: 7vw;
		display: block;
		float: left;
		margin: 2vw 0;
		text-align: center;
	}

	.cy_user_input {
		width: 20vw;
		height: 7vw;
		display: block;
		float: right;
		background: url(../../static/img/but.png)no-repeat top center;
		background-size: 100%;
		text-align: center;
		line-height: 7vw;
		margin: 1vw 0;
	}

	.cy_user_into text {
		margin-right: 2vw;
	}

	.cy_list {
		width: 90%;
		height: auto;
		display: block;
		float: left;
		margin: 1vw 5%;
		box-shadow:0px 0px 5px #F2F2F2;
		border-radius:1vw;
		padding: 4vw;
		background: #fff;
		margin-bottom: 10vw;
	}

	.cy_li {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		/* margin-bottom: 4vw; */
		border-bottom: 1px solid #F2F2F2;
		padding: 4vw 0;
	}

	.cy_li:last-child {
		border: none;
	}

	.cy_li image {
		width: 10vw;
		height: 10vw;
		display: block;
		float: left;
		margin: 2vw 0;
		border: ;
	}

	.cy_li_tit {
		width: 50%;
		height: 10vw;
		line-height: 10vw;
		display: block;
		float: left;
	}

	.cy_li_info {
		width: 100%;
		height: auto;
		line-height: 7vw;
		display: block;
		float: left;
	}

	.tri {
		text-align: right;
	}

	.cy_list_tit {
		width: 100%;
		height: auto;
		line-height: 12vw;
		display: block;
		float: left;
		text-align: center;
		background: #fff;
	}
	.cy_li_i{width: auto;margin-right: 3vw;}
	.cy_li image.cy_li_info_img{width: 2vw;float: right;}
</style>
